@extends('backend::modal')
@section('title',$page_title)
@push('styles')
    <link href="{{asset(config('view.plugin').'/layui/layui_ext/dtree/font/dtreefont.css')}}" rel="stylesheet">
    <link href="{{asset(config('view.plugin').'/layui/layui_ext/dtree/dtree.css')}}" rel="stylesheet">
@endpush
@section('content')
    <div class="row">
        <div class="col-lg-12">
            @if($roles)
                @component('backend::component.form.form')
                @slot('page_title') {{$page_title}} @endslot
                @slot('formId') grant-role @endslot
                @slot('action') {{route('b_Admin_grantRoles',['admin_name'=>$admin_name])}} @endslot
                    @component('backend::component.form.form-group')
                        @slot('title') 分配角色 @endslot
                        <div>
                            @foreach($roles as $id=>$title)
                                @component('backend::component.checkbox')
                                    @slot('title') {{$title}} @endslot
                                    @slot('name') my_roles[] @endslot
                                    @slot('value') {{$id}} @endslot
                                    @if(in_array($id,str2arr($my_roles)))
                                        @slot('checked') checked @endslot
                                    @endif
                                @endcomponent
                            @endforeach
                        </div>
                    @endcomponent

                @slot('buttons')
                    @component('backend::component.form.button')
                        @slot('title') 提交 @endslot
                        @slot('params') {"formId":"#grant-role"} @endslot
                        @slot('class') btn-min-width ajax-form @endslot
                    @endcomponent
                    @component('backend::component.form.button')
                        @slot('title') 重置 @endslot
                        @slot('type') reset @endslot
                        @slot('color') danger @endslot
                        @slot('class') btn-min-width @endslot
                    @endcomponent
                @endslot
            @endcomponent
            @else
                @component('backend::component.tpl_frame')
                    @slot('page_title'){{$page_title}}@endslot
                    @slot('body_content')
                        @include('backend::public.empty_page',['info'=>'没有可授权的角色'])
                    @endslot
                @endcomponent
            @endif
        </div>
        <!--/.col-->
    </div>
@endsection
@push('scripts')
    <script>
        layui.use(['element','layer', 'dtree'], function(){
            var layer = layui.layer,
                dtree = layui.dtree,
                $ = layui.$;

        });
    </script>
@endpush